﻿<Window x:Class="CncConvProg.View.EditWorkView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:MVVM_Library="clr-namespace:CncConvProg.ViewModel.MVVM_Library;assembly=CncConvProg.ViewModel" xmlns:GraphicViewer="clr-namespace:GraphicViewer;assembly=GraphicViewer" Title="EditWorkView" MinHeight="600" MinWidth="600"
        WindowStyle="ToolWindow"
        WindowState="Normal"
        Width="1024"
        Height="768"
        WindowStartupLocation="CenterScreen"
        >
    <Grid>
        <Grid.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="Controls/AppStyle.xaml"/>
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width=".4*" />
            <ColumnDefinition Width=".6*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="70" />
            <RowDefinition Height=".35*" />
            <RowDefinition Height=".5*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2">
            <Button Width="100" Margin="5"  Command="{Binding Path=PrevScreenCmd}">
                <StackPanel >
                    <TextBlock Text="Prev" TextWrapping="Wrap" HorizontalAlignment="Center" />
                    <Image Source="pack://application:,,,/CncConvProg.View;component/Images/Gui/back.png" Height="40"/>
                </StackPanel>
            </Button>
            <Button Width="Auto" Margin="5" Command="{Binding Path=UpdatePreviewCmd}" >
                <StackPanel >
                    <TextBlock Text="Update Preview" TextWrapping="Wrap" HorizontalAlignment="Center"/>
                    <Image Source="pack://application:,,,/CncConvProg.View;component/Images/Gui/refresh.png" Height="40"/>
                </StackPanel>
            </Button>

            <Button Width="100" Margin="5" Command="{Binding Path=NextScreenCmd}" >
                <StackPanel >
                    <TextBlock Text="Next" TextWrapping="Wrap" HorizontalAlignment="Center" />
                    <Image Source="pack://application:,,,/CncConvProg.View;component/Images/Gui/next.png" Height="40"/>
                </StackPanel>
            </Button>
            <TextBlock Text="{Binding Path=SelectedScreen.Label}" Grid.Column="2" FontSize="28" DockPanel.Dock="Left" Margin="35,0,0,0" VerticalAlignment="Center" FontWeight="DemiBold"/>
        </StackPanel>

        <TreeView ItemsSource="{Binding Path=TreeView}" Grid.RowSpan="1"  Grid.ColumnSpan="1" Grid.Row="1" Margin="0,0,8,0">
            <TreeView.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="PowderBlue" />
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />

                <HierarchicalDataTemplate DataType="{x:Type MVVM_Library:TreeViewItemViewModel}" ItemsSource="{Binding Children}" >
                    <Border  Margin="2,2,2,0" >
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="0,0,5,0"  HorizontalAlignment="Left" VerticalAlignment="Center">
                                <Image.Style>
                                    <Style>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path= IsSelected}" Value="True">
                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/currentItem.png" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Image.Style>
                            </Image>
                            <TextBlock Text="{Binding Path=Label}">
                                <TextBlock.Style>
                                    <Style>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path= IsSelected}" Value="True">
                                                <Setter Property="TextBlock.FontWeight" Value="DemiBold" />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                            </TextBlock>
                            <Image Width="16" Height="16" Margin="15,0,0,0"  HorizontalAlignment="Left" VerticalAlignment="Center">
                                <Image.Style>
                                    <Style>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path= IsValid}" Value="False">
                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/errorMark_16.png"/>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding Path= IsValid}" Value="True">
                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/okCheck_16.png"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Image.Style>
                            </Image>
                        </StackPanel>
                    </Border>
                </HierarchicalDataTemplate>

            </TreeView.Resources>
            <TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">
                    <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                    <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </TreeView.ItemContainerStyle>
        </TreeView>

        <ContentControl Content="{Binding Path=SelectedScreen}" Grid.Column="2" Grid.Row="1" Grid.ColumnSpan="2" Grid.RowSpan="2">
            <ContentControl.Resources>
                <ResourceDictionary>
                    <ResourceDictionary.MergedDictionaries>
                        <ResourceDictionary  Source="EditWorkViewResources.xaml">
                        </ResourceDictionary>
                    </ResourceDictionary.MergedDictionaries>
                </ResourceDictionary>
            </ContentControl.Resources>
        </ContentControl>

        <DockPanel Grid.ColumnSpan="4" Grid.Row="3">
            <Image DockPanel.Dock="Left" Width="48" Height="48" Margin="2" HorizontalAlignment="Left" VerticalAlignment="Center">
                <Image.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path= IsValid}" Value="False">
                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/warning_48.png"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Path= IsValid}" Value="True">
                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/ok_48.png"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Image.Style>
            </Image>
            <TextBlock VerticalAlignment="Center" FontSize="22" Margin="4">
                   <TextBlock.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path= IsValid}" Value="False">
                                <Setter Property="TextBlock.Text" Value="Work Not Defined"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Path= IsValid}" Value="True">
                                <Setter Property="TextBlock.Text" Value="Work Defined"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
            </TextBlock>

            <StackPanel Orientation="Horizontal" Grid.Row="3" HorizontalAlignment="Right" >
                <Button Width="100" Margin="5" Click="Button_Click_1" >
                    <StackPanel >
                        <TextBlock Text="Cancel" HorizontalAlignment="Center" />
                        <Image Source="pack://application:,,,/CncConvProg.View;component/Images/Gui/cancel.png" Height="40"/>
                    </StackPanel>
                </Button>
                <Button Width="100" Margin="5" Click="Button_Click" >
                    <StackPanel >
                        <TextBlock Text="Ok" HorizontalAlignment="Center" />
                        <Image Source="pack://application:,,,/CncConvProg.View;component/Images/Gui/ok.png" Height="40"/>
                    </StackPanel>
                </Button>
            </StackPanel>
        </DockPanel>
        <GridSplitter Width="5" Grid.Row="1" Grid.Column="0" Grid.RowSpan="3"/>

        <GridSplitter 
            ResizeDirection="Rows" 
            Grid.Column="0" 
            Grid.ColumnSpan="1"
            Grid.Row="2" 
            Width="Auto"
            Height="6"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Top"
            Margin="0"/>
        <GraphicViewer:Viewer3D  DataContext="{Binding Path = Preview}" Grid.Row="2" Margin="0,8,8,0" Grid.ColumnSpan="1" />
    </Grid>
</Window>
